package com.master.common.utils;

import java.io.Serializable;

/**
 * @author Heath.Que
 * @version 1.0
 * @classname
 * @description 结果返回包装类
 * @Date 2021/3/24 17:59
 **/
public class Result implements Serializable {

    private boolean success;

    private Integer code;

    private String message;

    private Object data;

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(boolean success, Integer code, String message, Object data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Result create(boolean success, Integer code, String message, Object data){
        return  new Result(success, code, message, data);
    }

    public static Result success(Object data){
        return new Result(true, 200, "success", data);
    }

    public static Result success(){
        return new Result(true, 200, "success", null);
    }

    public static Result fail(String message){
        return new Result(false, 400, message, null);
    }

    public static Result fail(){
        return new Result(false, 400, "fail", null);
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
